package com.sptpc.demo.global.exception;

import com.sptpc.demo.global.response.GlobalResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public GlobalResponse handleException(BusinessException e){
        return GlobalResponse.builder()
                .code(e.getError().getCode())
                .msg(e.getError().getMsg())
                .data(null)
                .build();
    }
}
